
app.controller('userListCtrl', ['$scope', function($scope) {
	
	var userName = Utils.getUrlParam("userName");
	
	lookUserInfo() ;
	refreshDataList();
	
	function lookUserInfo() {
		var param = {
			userName: userName,
		};
		AQ.callAQ("getUserInfoByuName.do", param, function(result) {			
			var UserInfo = result[1];
			UserInfo.identityPic = DIC.IdentityPic[UserInfo.identityLevel];
			UserInfo.vipPic = DIC.VipPic[UserInfo.vip];
			switch(parseInt(UserInfo.sex)) {
				case 0: UserInfo.sex = "保密"; break;
				case 1: UserInfo.sex = "男"; break;
				case 2: UserInfo.sex = "女"; break;
			}
			var old = Utils.nowDate().split("-")[0] - UserInfo.birthday.split(",")[0];
			UserInfo.birthday = old > 50 ? "保密" : old+"岁";
			UserInfo.createTime = UserInfo.createTime.substr(0, 10);
			$scope.$apply(function() {
				$scope.UserInfo = UserInfo;
			});
		}, function(err, code) {
			Utils.msgDialog(err + "["+ code +"]");
		});
	}
	
	function refreshDataList() {
		var param = {
			userName: userName,
			startTime: null,
			endTime: null,
			pageNo: 1,
			pageCount: 15,
		};
		AQ.callAQJSON("getUserNewEntry.do", param, function(result) {
			var list = result.data;
			var data = [];
			for (var i=0; i<list.length; i++) {
				var forumEntry = list[i];
				forumEntry.cateName = DIC.ForumCate(forumEntry.categoryId);
				data.push(forumEntry);
			}
			$scope.$apply(function () {
				$scope.listData = data;
			});
		}, function(err, code) {
			Utils.msgDialog(err + "["+ code +"]");
		});
	}
	
	
}]);
